//
//  Car.m
//  course1
//
//  Created by yc on 15/8/1.
//  Copyright (c) 2015年 yc. All rights reserved.
//

#import "Header.h"

@implementation HttpManager
- (void)sendGetOfUrl:(NSString *)url andMap:(NSDictionary *)map onSuccess:(void (^)(NSString *))success
             failure:(void (^)(NSError *error))failure{
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    
    // 带参数的GET请求
    [manager GET:url
       parameters:map
          success:^(AFHTTPRequestOperation *operation, id responseObject) {
              
              NSString *requestTmp = [NSString stringWithString:operation.responseString];
              //   NSLog(@"result1 = %@", requestTmp);
              
//              NSData *resData = [[NSData alloc] initWithData:[requestTmp dataUsingEncoding:NSUTF8StringEncoding]];
//              
//              NSError *error = nil;
//              NSDictionary * rootDic = [NSJSONSerialization JSONObjectWithData:resData options:NSJSONReadingMutableLeaves error:&error];
//              NSDictionary *result = [rootDic objectForKey:@"result"];
//              NSString *code = [result objectForKey:@"code"];
//              NSLog(@"code = %@", code);
              
              success(requestTmp);
              
              
          }
          failure:^(AFHTTPRequestOperation *operation, NSError *error) {
              failure(error);
          }];
}
@end
